-----------------------------------------------------------------------
-- File:        Turnout_Controller.adb
-- Description: Provide an interface to the hardware control of turnouts,
--				ensures the turning of requested turnout is done properly
--				and reports to enquiring modules about turnouts status
--
-- Requires:    Io_Ports,Unsigned_Types,Raildefs,Dio192defs, Dda06defs,
--              Int32defs
--
--
-- Author:     Maria Mitrevska
-----------------------------------------------------------------------
with Io_Ports;
with Unsigned_Types;
use Unsigned_Types;  -- 1.8
with Raildefs,
   Dio192defs, Dda06defs, Int32defs;
use Raildefs;


package Turnout_Controller is --ACTIVE (SPORADIC and PROTECTED objects)

   --Set a turnout (Tn) to direction Dir
   --Call Get_Status later in the process to check if turning is completed
   procedure Set_Turnout (
         Tn  : in     Raildefs.Turnout_Id;
         Dir : in     Raildefs.Turnout_Pos);

   --Init all Turnouts to Straighten position
   procedure Init_Turnouts;

   --Get turnout status
   --If error occured and turning could not be completed
   --Or not done yet, False is returned
   function Get_Status (
         Tn : in     Raildefs.Turnout_Id)
     return Boolean;

   --Set turnout status
   procedure Set_Status (
         Tn     : in     Raildefs.Turnout_Id;
         Status : in     Boolean);

   --Retry turnout
   --Reset the turnout to the last position as
   -- set by Set_Turnout
   procedure Retry_Turnout (
         Tn : in     Raildefs.Turnout_Id);
		
   --Get turnout position:
   --If error occured and turning could not be completed
   --Or not done yet, Middle is returned
   function Get_Position (
         Tn : in     Raildefs.Turnout_Id)
     return Turnout_Pos;

   --Start turnout status update
   --Internally used
   procedure Start (
         T_Id : in     Turnout_Id);


end Turnout_Controller;